﻿using System;
using System.ComponentModel.Composition;
using MEF_Test.Contracts;
using System.Windows.Input;
using MEF_Test.Bricks.Mediator;


namespace ModuleOne
{
    [Export(typeof(IModuleThumbnail))]
    public class PartOne : IModuleThumbnail
    {
       
        public PartOne()
        {                        
            // Tricky part:
            // We need to navigate to a resource located *outside* of the "current" assembly. Current assembly being the assembly containing the frame in which th navigation will take place !
            // therefore, we have to use a special syntax, as using only "ModuleOneBrowser.xaml" would not be resolved correctly : the page would only be look for in the MEF-Test.exe assembly !
            // the pack syntax (pack://application:,,,/ModuleOne;component/ModuleOneBrowser.xaml) can be used for a UriString (specifying an absolute path) as well as the following - simpler - syntax, using a relative path.
            // Mind the leading forward slash as this is a relative path !! Moduleone is the name of the assembly (without extension) component is a reserved name, and subfolders within the assembly can be used as well.           
            
            ModuleActivationCommand = new ParameterlessCommand(() => Mediator<LoadModuleMediation>.Publish(new LoadModuleMediation(){ModuleUri= new Uri("/Moduleone;component/ModuleOneBrowser.xaml", UriKind.Relative)}), () => true);            
            Caption = "Part one";
        }

        public string Caption { get; set; }

        public ICommand ModuleActivationCommand { get; set; }
       
    }
}
